package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class cls = String.class;
        //获取类对象表示的类的完全限定名
        String name = cls.getName();
        System.out.println(name);
        //仅获取类名
        name = cls.getSimpleName();
        System.out.println(name);

//        String pname = cls.getPackage().getName();
//        System.out.println("包名：" + pname);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个包名");
        String  className = scanner.nextLine();
        Class cls1 = Class.forName(className);

        Method[] methods = cls1.getMethods();
        for (Method method : methods) {
            System.out.println(method.getName());
        }
    }
}
